-
Notifications
You must be signed in to change notification settings - Fork 86
image: add image layout validation #84
Conversation
c9272dd to
ce32d77
Compare
|
|
|
opencontainers/image-spec#459 has clarify that |
|
I think the presence of |
image/autodetect.go
Outdated
|
|
||
| if fi.IsDir() { | ||
| for _, file := range Layoutfile { | ||
| if _, err = os.Stat(path + file); os.IsNotExist(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have to also make sure that each item is a directory or file (oci-layout must be a file).
Use filepath.Join here. Using + doesn't work correctly cross-platform.
image/autodetect.go
Outdated
| if fi.IsDir() { | ||
| for _, file := range Layoutfile { | ||
| if _, err = os.Stat(path + file); os.IsNotExist(err) { | ||
| return "", errors.New("unknown media type") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this more specific.
image/autodetect.go
Outdated
|
|
||
| // Layoutfile realize the image files that are included in the image layout type | ||
| var Layoutfile = []string{ | ||
| "/blobs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for leading slash: use filepath.Join.
cb75f90 to
63b3fc4
Compare
|
If we just support image layout, image, manifest, manifestlist and image config, there is no need to add layout validation in autodetect. Because if the input is a directory, it should be considered as a image layout. Only image layout could be a directory in supported type validation |
image/autodetect.go
Outdated
| var Layoutfile = []string{ | ||
| "blobs", | ||
| "oci-layout", | ||
| "refs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is changed now. There is no longer a ./refs/ directory. And there is an index.json file. See the updated image-layout.md doc.
8adac93 to
70d4a8e
Compare
|
@q384566678 The Travis CI failed, I think you need to fix TestValidateLayout in image_test.go |
I'm doing, but there are some content to wait for |
3dfb290 to
148e4ba
Compare
4b9bdae to
fe62cfe
Compare
|
Some methods in #50 are used to update the validation of layout. |
a5f7c1c to
2773bda
Compare
|
reping @opencontainers/image-tools-maintainers I hope you can take a moment to review this PR, which is an important validation that is missing. |
image/layout.go
Outdated
| "github.com/pkg/errors" | ||
| ) | ||
|
|
||
| var blobsExist, indexExist, layoutExist bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we put these into layoutValidate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, updated.
Signed-off-by: zhouhao <[email protected]>
Increase the validation of the files contained in the layout.
Including
blobs,oci-layoutandindex.jsonfiles.Signed-off-by: zhouhao [email protected]